import Vue from 'vue'
import App from './App'
import vueWaves from 'vue-waves'
import Router from 'vue-router'
import VueResource from 'vue-resource'
import vuetable from 'src/components/vue-table/Vuetable'
import VuetablePagination from 'src/components/vue-table/VuetablePagination'
import VuetablePaginationDropdown from 'src/components/vue-table/VuetablePaginationDropdown'
import RowDetail from 'src/components/vue-table/RowDetail'
Vue.use(vueWaves)
Vue.use(Router)
Vue.use(VueResource)
Vue.component('vuetable', vuetable)
Vue.component('vuetable-pagination', VuetablePagination)
Vue.component('vuetable-pagination-dropdown', VuetablePaginationDropdown)
Vue.component('my-detail-row', RowDetail)

var router = new Router({hashbang: false})
const rootView = './view/'

router.map({
  '/home': {
    component (resolve) {
      require([rootView + 'HomeView'], resolve)
    }
  },
  '/tables': {
    component (resolve) {
      require([rootView + 'TablesView'], resolve)
    }
  },
  '/data-tables': {
    component (resolve) {
      require([rootView + 'DataTablesView'], resolve)
    }
  },
  '/level-link': {
    component (resolve) {
      require([rootView + 'Level2View'], resolve)
    }
  },
  '/gd-map': {
    component (resolve) {
      require([rootView + 'GdMapView'], resolve)
    }
  }
})

router.beforeEach(function () {
  window.scrollTo(0, 0)
})

router.redirect({
  '*': '/home'
})

router.start(App, '#app')
